import path from 'node:path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import VueDevTools from 'vite-plugin-vue-devtools';
import Unocss from 'unocss/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
// https://vite.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      '~/': `${path.resolve(__dirname, 'src')}/`,
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "~/styles/theme/index.scss" as *;`,
      },
    },
  },
  plugins:
  [
    vue(),
    VueDevTools(),
    Components({
      dts: 'components.d.ts',
      dirs: [],
      globs: [],
      resolvers: [ElementPlusResolver({
        importStyle: 'sass',
        directives: true,
      })],
    }),
    Unocss(),
  ],
  build: {
    rollupOptions: {
      output: {
        manualChunks: (id: string) => {
          if (id.includes('node_modules')) {
            return 'vender';
          }
        },
      },
    },
  },

});
